import java.util.Scanner;
import java.util.InputMismatchException;
public class Lab05Task04 {
public static void main(String[] args) {
int choice;
double a,p,d,w,c;
Scanner kb=new Scanner(System.in);
try {
System.out.println("Enter your choise [1 or 2]:\n\n1. Find area and perimeter of a rectangle\n2. Find area and circumference of a circle");
choice=kb.nextInt();
switch (choice) {
case 1:
System.out.println("Please enter the diagonal of your rectangle [cm]:");
d=kb.nextDouble();
System.out.println("Please enter the width of your rectangle [cm]:");
w=kb.nextDouble();
a=w*Math.sqrt(d*d-w*w);
p=2*(Math.sqrt(d*d-w*w))+2*w;
System.out.printf("area=%.2f aquare cm, perimeter=%.2f cm",a,p);
break;
case 2:
System.out.println("Please enter the circumference of your circle [cm]:");
c=kb.nextDouble();
a=Math.pow(c, 2)/(4*Math.PI);
System.out.printf("area=%.2f aquare cm",a);
break;
default:
System.err.print("Error: Wrong menu choice");
break;
}
}
catch(InputMismatchException e) {
System.err.print("Error: "+e);
}
}
}